package cn.itchao.example.goods.api.service;

import cn.itchao.example.goods.api.GoodsServiceApi;
import cn.itchao.example.goods.domain.Goods;
import cn.itchao.example.goods.service.GoodsService;
import cn.itchao.exmaple.base.ApiResponse;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@Service
@RestController
@RefreshScope
public class GoodsServiceApiImpl implements GoodsServiceApi {

    @Autowired
    private GoodsService goodsService;

    @GetMapping(value = "/goods/{id}")
    @Override
    public ApiResponse<Goods> findGoodsById(@PathVariable("id") Long id) {
        Goods goods = goodsService.findGoodsById(id);
        return ApiResponse.ofSuccess(goods);
    }
}
